#ifndef __HTTPHANDLERTASK_H_
#define __HTTPHANDLERTASK_H_
#include "KLib.h"
#include "Task.h"
#include "Socket.h"
#include "Thread.h"
SK

class HTTPServer;


typedef struct _RequestInfo
{
    String method;
    String url;
    String mimeType;
    bool keepAlive;
    KeyValuePair headers;
}RequestInfo;

class HTTPHandlerTask : public Task
{
private:
    HTTPServer *server;
    Socket *con;
    RequestInfo *requestInfo;
    String response;
    String root;
    Thread *thread;

    void parseMimeType (const String& url);
    void parseRequest (const String& request);
    bool processRequest (void);
    void sendResponse (void);
public:
    HTTPHandlerTask (HTTPServer *server, Thread *t, Socket *con, const String& siteRoot);
    virtual ~HTTPHandlerTask ();

    virtual void run (void);
};

EK

#endif